package com.sise.bl.entity;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 对应数据库的用户表
 */
@Component
public class User implements Serializable {

    private static final long serialVersionUID = 1L;
    private Integer uid;
    private String username;  //对应的是数据库的uname字段
    private String upassword; //密码
    private String usex; //性别
    private Integer ustatus; //用户的激活状态 0 未激活 1 激活
    private String code; //邮件激活码
    private String email; //对应的是数据库的uemail字段
    private Integer urole; //用户 0 管理员 1
    private Set<Address> addresses = new HashSet<Address>();
    private Set<Orders> orders = new HashSet<Orders>();
    private Set<Cart> carts = new HashSet<Cart>();

    public User() {
    }

    public User(String username, String upassword, String usex, Integer ustatus, String code, String email, Integer urole) {
        this.username = username;
        this.upassword = upassword;
        this.usex = usex;
        this.ustatus = ustatus;
        this.code = code;
        this.email = email;
        this.urole = urole;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUpassword() {
        return upassword;
    }

    public void setUpassword(String upassword) {
        this.upassword = upassword;
    }

    public String getUsex() {
        return usex;
    }

    public void setUsex(String usex) {
        this.usex = usex;
    }

    public Integer getUstatus() {
        return ustatus;
    }

    public void setUstatus(Integer ustatus) {
        this.ustatus = ustatus;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getUrole() {
        return urole;
    }

    public void setUrole(Integer urole) {
        this.urole = urole;
    }

    public Set<Address> getAddresses() {
        return addresses;
    }

    public void setAddresses(Set<Address> addresses) {
        this.addresses = addresses;
    }

    public Set<Orders> getOrders() {
        return orders;
    }

    public void setOrders(Set<Orders> orders) {
        this.orders = orders;
    }

    public Set<Cart> getCarts() {
        return carts;
    }

    public void setCarts(Set<Cart> carts) {
        this.carts = carts;
    }

    @Override
    public String toString() {
        return "User{" +
                "uid=" + uid +
                ", username='" + username + '\'' +
                ", upassword='" + upassword + '\'' +
                ", usex='" + usex + '\'' +
                ", ustatus=" + ustatus +
                ", code='" + code + '\'' +
                ", email='" + email + '\'' +
                ", urole=" + urole +
                ", addresses=" + addresses +
                ", orders=" + orders +
                ", carts=" + carts +
                '}';
    }
}
